//
//  RequestManager.m
//  lcf-newproject
//
//  Created by yangyang on 14-11-17.
//  Copyright (c) 2014年 yang. All rights reserved.
//

#import "RequestManager.h"

static RequestManager * requestManager = nil;
@interface RequestManager()
//缓存所有请求的request对象
@property(nonatomic, strong) NSMutableDictionary *requestDic;
@end

@implementation RequestManager

//创建网络请求管理对象单例
+(RequestManager *)shareRequestManager{
    static dispatch_once_t  onceToken;
    dispatch_once(&onceToken, ^{
        requestManager = [[RequestManager alloc]init];
    });
    return requestManager;
    
}
//重写init方法
-(id)init{
    self = [super init];
    if (self) {
        self.requestDic = [[NSMutableDictionary alloc]init];
    }
    return self;
}

//将request对象添加到字典中,key为请求地址
-(void)setRequest:(id)request forKey:(NSString *)key{
    if (request) {
        [self.requestDic setObject:request forKey:key];
    }
}
//从字典中移除对象
-(void)removeRequestForKey:(NSString *)key{
    if (self.requestDic) {
        [self.requestDic removeObjectForKey:key];
    }
}

@end
